﻿using System;
using System.Configuration;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using DiscoveryLogic.DataServices.DataObjects;

namespace DiscoveryLogic.DataServices
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Banking:IBanking
    {
        private readonly string accountsFile = ConfigurationManager.AppSettings["AccountsXML"];

        
        public Account[] GetAccounts()
        {
            //List<Microsoft.SilverLight.BankingDemo.Models.Account> accountList = ModelFactory<List<Microsoft.SilverLight.BankingDemo.Models.Account>>.Load(accountsFile);
            //return accountList.ToArray();

            Account[] ret = ModelFactory<Account[]>.Deserialize ( accountsFile ) ;
            return ret; 
             
        }


        private readonly string payeesFile = ConfigurationManager.AppSettings["BillPayXML"];

        public BillPayee[] GetPayees()
        {
           return ModelFactory<BillPayee[]>.Deserialize ( payeesFile ) ; 
        }


        private readonly string mortgageFile = ConfigurationManager.AppSettings["MortgageXML"];


        public MortgageAccount GetMortgage()
        {
            return ModelFactory<MortgageAccount>.Deserialize(mortgageFile);
        }


        private readonly string portfolioFile = ConfigurationManager.AppSettings["PortfolioXML"];


        public InvestmentPortfolio GetPortfolio()
        {
            
            return  ModelFactory<InvestmentPortfolio>.Deserialize(portfolioFile);
             
        }


        private readonly string statementsFile = ConfigurationManager.AppSettings["StatementsXML"];


      
      
        
        public Statement[] GetStatements()
        {
            return ModelFactory<Statement[]>.Deserialize(statementsFile);              
        }

    }
}
